import address from '../../api/address/index.js'

const welcome = {

    myInfo: {
        city: '苏州', province: '江苏', country: '中国', ip: '127.0.0.1', location: {
            lat: 31.322323, lng: 120.563012
        },
    },

    showWelcome: async () => {
        let response = await address.getLocation.get();
        let dist = welcome.getDistance(welcome.myInfo.location.lng, welcome.myInfo.location.lat, response.location.lng, response.location.lat);
        let welcomeInfo;
        switch (response.country) {
            case "日本":
                welcomeInfo = "よろしく，一起去看樱花吗";
                break;
            case "美国":
                welcomeInfo = "Let us live in peace!";
                break;
            case "英国":
                welcomeInfo = "想同你一起夜乘伦敦眼";
                break;
            case "俄罗斯":
                welcomeInfo = "干了这瓶伏特加！";
                break;
            case "法国":
                welcomeInfo = "C'est La Vie";
                break;
            case "德国":
                welcomeInfo = "Die Zeit verging im Fluge.";
                break;
            case "澳大利亚":
                welcomeInfo = "一起去大堡礁吧！";
                break;
            case "加拿大":
                welcomeInfo = "拾起一片枫叶赠予你";
                break;
            case "中国":
                switch (response.province) {
                    case "北京市":
                        welcomeInfo = "北——京——欢迎你~~~";
                        break;
                    case "天津市":
                        welcomeInfo = "讲段相声吧";
                        break;
                    case "河北省":
                        welcomeInfo = "山势巍巍成壁垒，天下雄关铁马金戈由此向，无限江山";
                        break;
                    case "山西省":
                        welcomeInfo = "展开坐具长三尺，已占山河五百余";
                        break;
                    case "内蒙古自治区":
                        welcomeInfo = "天苍苍，野茫茫，风吹草低见牛羊";
                        break;
                    case "辽宁省":
                        welcomeInfo = "我想吃烤鸡架！";
                        break;
                    case "吉林省":
                        welcomeInfo = "状元阁就是东北烧烤之王";
                        break;
                    case "黑龙江省":
                        welcomeInfo = "很喜欢哈尔滨大剧院";
                        break;
                    case "上海市":
                        welcomeInfo = "众所周知，中国只有两个城市";
                        break;
                    case "江苏省":
                        switch (response.city) {
                            case "南京市":
                                welcomeInfo = "这是我挺想去的城市啦";
                                break;
                            case "苏州市":
                                welcomeInfo = "上有天堂，下有苏杭";
                                break;
                            default:
                                welcomeInfo = "散装是必须要散装的";
                                break;
                        }
                        break;
                    case "浙江省":
                        welcomeInfo = "东风渐绿西湖柳，雁已还人未南归";
                        break;
                    case "河南省":
                        switch (response.city) {
                            case "郑州市":
                                welcomeInfo = "豫州之域，天地之中";
                                break;
                            case "南阳市":
                                welcomeInfo = "臣本布衣，躬耕于南阳此南阳非彼南阳！";
                                break;
                            case "驻马店市":
                                welcomeInfo = "峰峰有奇石，石石挟仙气嵖岈山的花很美哦！";
                                break;
                            case "开封市":
                                welcomeInfo = "刚正不阿包青天";
                                break;
                            case "洛阳市":
                                welcomeInfo = "洛阳牡丹甲天下";
                                break;
                            default:
                                welcomeInfo = "可否带我品尝河南烩面啦？";
                                break;
                        }
                        break;
                    case "安徽省":
                        welcomeInfo = "蚌埠住了，芜湖起飞";
                        break;
                    case "福建省":
                        welcomeInfo = "井邑白云间，岩城远带山";
                        break;
                    case "江西省":
                        welcomeInfo = "落霞与孤鹜齐飞，秋水共长天一色";
                        break;
                    case "山东省":
                        welcomeInfo = "遥望齐州九点烟，一泓海水杯中泻";
                        break;
                    case "湖北省":
                        switch (response.city) {
                            case "黄冈市":
                                welcomeInfo = "红安将军县！辈出将才！";
                                break;
                            default:
                                welcomeInfo = "来碗热干面~";
                                break;
                        }
                        break;
                    case "湖南省":
                        welcomeInfo = "74751，长沙斯塔克";
                        break;
                    case "广东省":
                        switch (response.city) {
                            case "广州市":
                                welcomeInfo = "看小蛮腰，喝早茶了嘛~";
                                break;
                            case "深圳市":
                                welcomeInfo = "今天你逛商场了嘛~";
                                break;
                            case "阳江市":
                                welcomeInfo = "阳春合水！博主家乡~ 欢迎来玩~";
                                break;
                            default:
                                welcomeInfo = "来两斤福建人~";
                                break;
                        }
                        break;
                    case "广西壮族自治区":
                        welcomeInfo = "桂林山水甲天下";
                        break;
                    case "海南省":
                        welcomeInfo = "朝观日出逐白浪，夕看云起收霞光";
                        break;
                    case "四川省":
                        welcomeInfo = "康康川妹子";
                        break;
                    case "贵州省":
                        welcomeInfo = "茅台，学生，再塞200";
                        break;
                    case "云南省":
                        welcomeInfo = "玉龙飞舞云缠绕，万仞冰川直耸天";
                        break;
                    case "西藏自治区":
                        welcomeInfo = "躺在茫茫草原上，仰望蓝天";
                        break;
                    case "陕西省":
                        welcomeInfo = "来份臊子面加馍";
                        break;
                    case "甘肃省":
                        welcomeInfo = "羌笛何须怨杨柳，春风不度玉门关";
                        break;
                    case "青海省":
                        welcomeInfo = "牛肉干和老酸奶都好好吃";
                        break;
                    case "宁夏回族自治区":
                        welcomeInfo = "大漠孤烟直，长河落日圆";
                        break;
                    case "新疆维吾尔自治区":
                        welcomeInfo = "驼铃古道丝绸路，胡马犹闻唐汉风";
                        break;
                    case "台湾省":
                        welcomeInfo = "我在这头，大陆在那头";
                        break;
                    case "香港特别行政区":
                        welcomeInfo = "永定贼有残留地鬼嚎，迎击光非岁玉";
                        break;
                    case "澳门特别行政区":
                        welcomeInfo = "性感荷官，在线发牌";
                        break;
                    default:
                        welcomeInfo = "带我去你的城市逛逛吧！";
                        break;
                }
                break;
            default:
                welcomeInfo = "带我去你的国家逛逛吧";
                break;
        }
        //根据本地时间切换欢迎语
        let timeChange;
        let date = new Date();
        if (date.getHours() >= 5 && date.getHours() < 11) timeChange = "<span>🌤️ 早上好，一日之计在于晨</span>"; else if (date.getHours() >= 11 && date.getHours() < 13) timeChange = "<span>☀️ 中午好，记得午休喔~</span>"; else if (date.getHours() >= 13 && date.getHours() < 17) timeChange = "<span>🕞 下午好，饮茶先啦！</span>"; else if (date.getHours() >= 17 && date.getHours() < 19) timeChange = "<span>🚶‍♂️ 即将下班，记得按时吃饭~</span>"; else if (date.getHours() >= 19 && date.getHours() < 24) timeChange = "<span>🌙 晚上好，夜生活嗨起来！</span>"; else timeChange = "夜深了，早点休息，少熬夜";
        let ip = response.ip;
        // 新增ipv6显示为指定内容
        if (ip.includes(":")) {
            ip = "<br>好复杂，咱看不懂~(ipv6)";
        }
        //自定义文本和需要放的位置
        return "欢迎来自 <b><span style=\"color: var(--hao-ip-color);font-size: var(--hao-gl-size)\">" + response.province + '&nbsp;' + response.city + "</span></b> 的小友💖<br>" + welcomeInfo + "🍂<br>当前位置距博主约 <b><span style=\"color: var(--hao-ip-color)\">" + dist + "</span></b> 公里！<br>您的IP地址为：<b><span>" + ip + "</span></b><br>" + timeChange + "<br>";
    },

    getDistance: (e1, n1, e2, n2) => {
        const R = 6371
        const {sin, cos, asin, PI, hypot} = Math
        let getPoint = (e, n) => {
            e *= PI / 180
            n *= PI / 180
            return {x: cos(n) * cos(e), y: cos(n) * sin(e), z: sin(n)}
        }

        let a = getPoint(e1, n1)
        let b = getPoint(e2, n2)
        let c = hypot(a.x - b.x, a.y - b.y, a.z - b.z)
        let r = asin(c / 2) * 2 * R
        return Math.round(r);
    },

};

export default welcome;


